package com.example.a623

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        var sp=getSharedPreferences("data", MODE_PRIVATE)
        if (sp.getString("flag","falsee").equals("true")){
            startActivity(Intent(applicationContext,Login::class.java))
        }
        else {

            var list = ArrayList<View>()
            list.add(layoutInflater.inflate(R.layout.guide1, null))
            list.add(layoutInflater.inflate(R.layout.guide2, null))
            list.add(layoutInflater.inflate(R.layout.guide3, null))
            viewPager.adapter = ViewPagerAdapter(list)

            list.get(2).findViewById<Button>(R.id.guide3_btn).setOnClickListener {
                var editor = sp.edit()
                editor.putString("flag", "true")
                editor.commit()

                startActivity(Intent(applicationContext, Login::class.java))
            }
        }
    }
}